package com.example.fp.cgc.connerlt

import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.scheduling.annotation.EnableAsync
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor
import java.util.concurrent.Executor

@Configuration //该类为启动配置信息
@EnableAsync //开启异步事件的注解
open class MyCon {
    //配置执行任务的相关值
    private val corePoolSize = 10
    private val maxPoolSize = 200
    private val queueCapactiy = 10
    @Bean
    open fun taskExecutor(): Executor {
        val executor = ThreadPoolTaskExecutor()
        executor.corePoolSize = corePoolSize
        executor.maxPoolSize = maxPoolSize
        executor.setQueueCapacity(queueCapactiy)
        executor.initialize()
        return executor
    }
}